function createHttpRequest()
{
  var httpRequest = false;

  var isMoziallaAndSafari = window.XMLHttpRequest;
  var isInternetExplorer = window.ActiveXObject;
  
  if (isMoziallaAndSafari) 
  { 
    httpRequest = new XMLHttpRequest();
    if (httpRequest.overrideMimeType) 
    {
      httpRequest.overrideMimeType('text/xml');
    }
  } 
  else if (isInternetExplorer) 
  { 
    try 
    {
      httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
      try 
      {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (e) 
      {}
    }
  }
  return httpRequest;
}


function callServerSideFunction(_phpFileUrl,_processResultsFunctionText,_async)
{
  if (_async == undefined)
  {
  	_async = true;
  }

  var httpRequest = createHttpRequest();

  if (!httpRequest) 
  {
    error('Cannot create an XmlHttp instance');
    return false;
  }


  httpRequest.onreadystatechange = function() {
    switch(httpRequest.readyState) {
      case 0: // Request is uninitialized.
      case 1: // Request has not been sent.
      case 2: // Request has been sent and is being processed.
      case 3: // Request is being processed.
        break;

      case 4: // Request is complete.
        if(httpRequest.status == 200) 
        {
          eval(_processResultsFunctionText);
        } 
        else 
        {
          error('Ajax Failed: ' + httpRequest.status);
        }
        break;
      }
    }

  _phpFileUrlParts = _phpFileUrl.split('?');
  var uri = noCache();
  uri = _phpFileUrlParts[0] + uri.replace('&', '?');
  var queryString = _phpFileUrlParts[1];

  httpRequest.open('POST', uri, _async);
  httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  httpRequest.send(queryString);
  return httpRequest;
}


// IE caches ajax requests.  Put a random string on the end of every request to ensure it is unique
function noCache()
{
  return '&' + "noCache=" + Math.random() * 10000;
}

function empty()
{}
